package nsga.chromosome;

import java.util.ArrayList;
import java.util.List;

import GA.chromosome.GAChrom;
import algorithm.AlgCtx;
import abstractGA.GAParameter;
import abstractGA.chrom.Chrom;
/**
 * 多目标NSGA不带学习机制的染色体
 * @author nyc
 *
 */
public class NSGAChrom extends GAChrom {
	
	public NSGAChrom() {
		super();
	}

	public NSGAChrom(List<StringBuffer> codes) {
		this.codes = codes;
	}

	/**
     * 构造函数
     * @param algCtx：算法运行上下文
     * @param parameter：参数
     */
	public NSGAChrom(AlgCtx algCtx,GAParameter parameter) {
		super(algCtx,parameter);
	}
	
	/**
	 * @return:复制并返回一条新的染色体
	 */
	public Chrom copy() {
		// 产生带学习机制的GA染色体
		NSGAChrom newChrom = new NSGAChrom();
		List<StringBuffer> newCodes = new ArrayList<StringBuffer>();
		int len = codes.size();
		for (int i = 0; i < len; i++) {
			String tempStr = codes.get(i).toString();
			newCodes.add(new StringBuffer(tempStr));
		}
		newChrom.codes = newCodes;
		
		ArrayList<Float> newObjVals = new ArrayList<Float>();
		for(Float objVal:objVals){
			newObjVals.add(objVal);
		}
		newChrom.objVals = newObjVals;

		newChrom.para = para;
		newChrom.random = random;
		newChrom.algOper = algOper;
		newChrom.listener = newChrom;
		return newChrom;
	}
}
